//////////////////////////////////////////////////////////////////////////////////////////
/////
/// This is part of a collection of libraries developed by Asaf Shelly
/// More about Asaf Shelly: http://Asaf.Shelly.co.il
/// More about the libraries: http://AsyncOp.com
///
/// You are permitted to use, copy, publish, execute and redistribute
/// this code and library free of charge for the duration of the copyright 
//
//////////////////////////////////////////////////////////////////////////////////////////
///// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
///// DEALINGS IN THE SOFTWARE
//////////////////////////////////////////////////////////////////////////////////////////
/////
/// For more details and an explicit legal permission you can contact me
/// directly:
/// Asaf Shelly
/// OpenSource@Shelly.co.il
/// http://AsyncOp.com
/// http://Asaf.Shelly.co.il
///
/// This code has been under development for over ten years and is still
/// updated occasionally.
/// It is recommended that you go online to find updates and fixed.
/// It is also recommended that you add a link in your code that is using
/// this or part of this source for future reference.
/// 
/// If you have any bug fixes, known bugs, updates, extensions, and other
/// comments feel free to post to the website or contact me directly.
//

// Peripherals.h is the header file with declerations for Peripherals.cpp implementing communication with system peripherals.
// By Asaf Shelly
// 26-11-2003

 #ifndef INCLUDE_FILE__PERIPHERALS_H__
  #define INCLUDE_FILE__PERIPHERALS_H__

  #include <windows.h>

   #ifndef __LINKAGE_WMD
     #define __LINKAGE_WMD
     #define __LINKAGE_WMD_TYPE 'L'
   #endif



 class __LINKAGE_WMD SerialPort
  {
   private:
   protected:
             HANDLE hPort;
             COMMTIMEOUTS commTimeOuts;
             DCB portDcb;
   public:

             SerialPort(int port=1);
             ~SerialPort();
             DWORD __stdcall Open(int port=-1);                     // -1=use constructor's.
             DWORD __stdcall Close();                     
             DWORD __stdcall Write(char* pBuffer, int length=-1);   // (len=-1)=pBuff is sz.
             DWORD __stdcall Read(char* pBuffer, int length, DWORD *pdwRead=NULL);
             DWORD __stdcall SetBaudRate(int rate);
             DWORD __stdcall SetDataBits(int bits);
             DWORD __stdcall SetParity(int parity);
             DWORD __stdcall SetStopBits(int bits);
             DWORD __stdcall SetFlowXonXoff(int flow);
             DWORD __stdcall SetTimeouts(int sec);
             DWORD __stdcall CommError(DWORD& errCode);
  };





 #endif // INCLUDE_FILE__PERIPHERALS_H__
